package com.threeti.mecool.common.resource.core;

import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;

import com.threeti.mecool.common.resource.Content;

public class ContentFactory {
	public static Content makeContent(Resource rs) {
		if (rs instanceof UrlResource) {
			if ((rs.getFilename().endsWith(".txt") || rs.getFilename().endsWith(".TXT")) || 
					(rs.getFilename().endsWith(".html")|| rs.getFilename().endsWith(".HTML"))) {//TODO jay:more flexible here
				return new DefaultPlainTextContent(rs);
			}
			return new DefaultContent(rs);
		}
		return null;//TODO jay:avoid null
	}
}
